package dowork;

import android.util.Log;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.sutuijingling.a.b;
import com.sutuijingling.bean.TopBean;
import com.sutuijingling.result.c;
import com.sutuijingling.result.p;
import com.sutuijingling.result.r;
import com.sutuijingling.result.s;
import com.sutuijingling.utils.a;
import java.util.Random;
import java.util.UUID;

public class NetflowApiTestRunner extends UiAutomatorTestCase {
    public static final String TAG = "NetflowApiTestRunner";

    public void testDoWork() {
        System.out.println(" res :" + a.b());
        Random random = new Random();
        String str = "58.100." + (random.nextInt(250) + 1) + "." + (random.nextInt(250) + 1);
        String substring = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16);
        Log.i(TAG, String.format(" ip [%s], key[%s], ", new Object[]{str, substring}));
        try {
            UiDevice uiDevice = getUiDevice();
            String str2 = (String) new s(substring, str).c();
            Log.i(TAG, " back netflow res:" + str2);
            b.a(uiDevice);
            String c = b.c();
            TopBean parseFromJson = TopBean.parseFromJson(str2, c);
            Log.i(TAG, " back netflow res:" + parseFromJson.toString());
            long taskId = parseFromJson.getTaskId();
            if (parseFromJson.getCode() == 7008) {
                Log.i(TAG, " no missions for current ip ::" + str);
                return;
            }
            str2 = (String) new r(taskId, substring).c();
            Log.i(TAG, " fetch id res:" + str2);
            Log.i(TAG, " back netflow res:" + TopBean.parseFromJson(str2, c).toString());
            Log.i(TAG, " finish res :" + ((Boolean) new p(Long.valueOf(taskId), substring).c()));
        } catch (c e) {
            e.printStackTrace();
        }
    }
}
